﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace Encryption
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Security security = new Security();

                if (args == null || args.Length < 2)
                {
                    log("Usage:  Encryption.exe [encrypt|decrypt] [text] <salt> <MD5|SHA256>");
                    return;
                }

                Security.EncryptionType type = Security.EncryptionType.MD5;

                if (args[0] == "encrypt")
                {
                    log(security.Encrypt(args[1], type));
                }
                else if (args[0] == "decrypt")
                {
                    log(security.Decrypt(args[1], type));
                }
            }
            catch (Exception ex)
            {
                log(ex.Message);
            }
        }



        static void log(string message)
        {
            Debug.Print(message);
            Console.WriteLine(message);            
        }                      
                
    }
}
